package net.begincode.convert;

import net.begincode.bean.UserBaseInfo;
import net.begincode.blog.entity.User;
import net.begincode.common.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

public class UserConvertUtils {
    public static List<UserBaseInfo> convert(List<User> userList){
        return CollectionUtils.safes(userList).stream()
                .map(UserConvertUtils::convert).collect(Collectors.toList());
    }
    public static UserBaseInfo convert(User user){
        UserBaseInfo userBaseInfo = new UserBaseInfo();
        userBaseInfo.setUserId(user.getUserId());
        userBaseInfo.setUserName(user.getNickName());
        return userBaseInfo;
    }
}
